#pragma once
#include "stdafx.h"
using namespace std;
class TokenType
{
public:
	multimap<string,int> reservadas;
	multimap<string,int>::iterator it;

	multimap<int,string> lexemas;
	multimap<int,string>::iterator it2;

	TokenType(void)
	{
		reservadas.insert (pair<string,int>("O",this->oprLogicoO));
		reservadas.insert (pair<string,int>("Y",this->oprLogicoY));
		reservadas.insert (pair<string,int>("FUNCION",this->revFuncion));
		reservadas.insert (pair<string,int>("ENTERO",this->revEntero));
		reservadas.insert (pair<string,int>("REAL",this->revReal));
		reservadas.insert (pair<string,int>("CARACTER",this->revCaracter));
		reservadas.insert (pair<string,int>("BOOLEANO",this->revBooleano));
		reservadas.insert (pair<string,int>("CADENA",this->revCadena));
		reservadas.insert (pair<string,int>("INICIO",this->revInicio));
		reservadas.insert (pair<string,int>("FIN",this->revFin));
		reservadas.insert (pair<string,int>("SI",this->revSi));
		reservadas.insert (pair<string,int>("NO",this->revNo));
		reservadas.insert (pair<string,int>("ENTONCES",this->revEntonces));
		reservadas.insert (pair<string,int>("SINO",this->revSino));
		reservadas.insert (pair<string,int>("CASO",this->revCaso));
		reservadas.insert (pair<string,int>("PARA",this->revPara));
		reservadas.insert (pair<string,int>("HASTA",this->revHasta));
		reservadas.insert (pair<string,int>("MIENTRAS",this->revMientras));
		reservadas.insert (pair<string,int>("REPITA",this->revRepita));
		reservadas.insert (pair<string,int>("ABRIR",this->revAbrir));
		reservadas.insert (pair<string,int>("CERRAR",this->revCerrar));
		reservadas.insert (pair<string,int>("COMO",this->revComo));
		reservadas.insert (pair<string,int>("VAR",this->revVar));
		reservadas.insert (pair<string,int>("TIPO",this->revTipo));
		reservadas.insert (pair<string,int>("ARCHIVO",this->revArchivo));
		reservadas.insert (pair<string,int>("SECUENCIAL",this->revSecuencial));
		reservadas.insert (pair<string,int>("REGISTRO",this->revRegistro));
		reservadas.insert (pair<string,int>("ARREGLO",this->revArreglo));
		reservadas.insert (pair<string,int>("DE",this->revDe));
		reservadas.insert (pair<string,int>("PROCEDIMIENTO",this->revProcedimiento));
		reservadas.insert (pair<string,int>("LLAMAR",this->revLlamar));
		reservadas.insert (pair<string,int>("ESCRIBA",this->revEscriba));
		reservadas.insert (pair<string,int>("LEA",this->revLea));
		reservadas.insert (pair<string,int>("VERDADERO",this->revVerdadero));
		reservadas.insert (pair<string,int>("FALSO",this->revFalso));
		reservadas.insert (pair<string,int>("DIV",this->revDiv));
		reservadas.insert (pair<string,int>("MOD",this->revMod));
		reservadas.insert (pair<string,int>("ES",this->revEs));
		reservadas.insert (pair<string,int>("LECTURA",this->revLectura));
		reservadas.insert (pair<string,int>("RETORNE",this->revRetorne));
		reservadas.insert (pair<string,int>("HAGA",this->revHaga));

		
		lexemas.insert (pair<int,string>(this->oprSuma,"+"));
		lexemas.insert (pair<int,string>(this->oprResta,"-"));
		lexemas.insert (pair<int,string>(this->oprLogicoO,"O"));
		lexemas.insert (pair<int,string>(this->oprLogicoY,"Y"));
		lexemas.insert (pair<int,string>(this->oprExpo,"^"));
		lexemas.insert (pair<int,string>(this->oprMult,"*"));
		lexemas.insert (pair<int,string>(this->oprDiv,"/"));
		lexemas.insert (pair<int,string>(this->oprMenor,"MAYOR"));
		lexemas.insert (pair<int,string>(this->oprMayor,"MENOR"));
		lexemas.insert (pair<int,string>(this->oprIgual,"IGUAL"));
		lexemas.insert (pair<int,string>(this->oprMenorIgual,"MENORIGUAL"));
		lexemas.insert (pair<int,string>(this->oprMayorIgual,"MAYORIGUAL"));
		lexemas.insert (pair<int,string>(this->oprAsig,"ASINAR_TOKEN"));
		lexemas.insert (pair<int,string>(this->oprDist,"DISTINTO"));
		lexemas.insert (pair<int,string>(this->pntcorIzq,"["));
		lexemas.insert (pair<int,string>(this->pntcorDer,"]"));
		lexemas.insert (pair<int,string>(this->pntComa,","));
		lexemas.insert (pair<int,string>(this->pntDosPuntos,":"));
		lexemas.insert (pair<int,string>(this->pntPunto,"."));
		lexemas.insert (pair<int,string>(this->pntparDer,")"));
		lexemas.insert (pair<int,string>(this->pntparIzq,"("));
		lexemas.insert (pair<int,string>(this->revFuncion,"FUNCION"));
		lexemas.insert (pair<int,string>(this->revEntero,"ENTERO"));
		lexemas.insert (pair<int,string>(this->revReal,"REAL"));
		lexemas.insert (pair<int,string>(this->revCaracter,"CARACTER"));
		lexemas.insert (pair<int,string>(this->revBooleano,"BOOLEANO"));
		lexemas.insert (pair<int,string>(this->revCadena,"CADENA"));
		lexemas.insert (pair<int,string>(this->revInicio,"INICIO"));
		lexemas.insert (pair<int,string>(this->revFin,"FIN"));
		lexemas.insert (pair<int,string>(this->revSi,"SI"));
		lexemas.insert (pair<int,string>(this->revNo,"NO"));
		lexemas.insert (pair<int,string>(this->revEntonces,"ENTONCES"));
		lexemas.insert (pair<int,string>(this->revSino,"SINO"));
		lexemas.insert (pair<int,string>(this->revCaso,"CASO"));
		lexemas.insert (pair<int,string>(this->revPara,"PARA"));
		lexemas.insert (pair<int,string>(this->revHasta,"HASTA"));
		lexemas.insert (pair<int,string>(this->revHaga,"HAGA"));
		lexemas.insert (pair<int,string>(this->revMientras,"MIENTRAS"));
		lexemas.insert (pair<int,string>(this->revRepita,"REPITA"));
		lexemas.insert (pair<int,string>(this->revAbrir,"ABRIR"));
		lexemas.insert (pair<int,string>(this->revCerrar,"CERRAR"));
		lexemas.insert (pair<int,string>(this->revComo,"COMO"));
		lexemas.insert (pair<int,string>(this->revVar,"VAR"));
		lexemas.insert (pair<int,string>(this->revLeer,"LEER"));
		lexemas.insert (pair<int,string>(this->revEscribir,"ESCRIBIR"));
		lexemas.insert (pair<int,string>(this->revTipo,"TIPO"));
		lexemas.insert (pair<int,string>(this->revArchivo,"ARCHIVO"));
		lexemas.insert (pair<int,string>(this->revSecuencial,"SECUENCIAL"));
		lexemas.insert (pair<int,string>(this->revRegistro,"REGISTRO"));
		lexemas.insert (pair<int,string>(this->revArreglo,"ARREGLO"));
		lexemas.insert (pair<int,string>(this->revDe,"DE"));
		lexemas.insert (pair<int,string>(this->revProcedimiento,"PROCEDIMIENTO"));
		lexemas.insert (pair<int,string>(this->revLlamar,"LLAMAR"));
		lexemas.insert (pair<int,string>(this->revEscriba,"ESCRIBA"));
		lexemas.insert (pair<int,string>(this->revLea,"LEA"));
		lexemas.insert (pair<int,string>(this->revVerdadero,"VERDADERO"));
		lexemas.insert (pair<int,string>(this->revFalso,"FALSO"));
		lexemas.insert (pair<int,string>(this->revDiv,"DIV"));
		lexemas.insert (pair<int,string>(this->revMod,"MOD"));
		lexemas.insert (pair<int,string>(this->revEs,"ES"));
		lexemas.insert (pair<int,string>(this->revLectura,"LECTURA"));
		lexemas.insert (pair<int,string>(this->revEscritura,"ESCRITURA"));
		lexemas.insert (pair<int,string>(this->revRetorne,"RETORNE"));
		lexemas.insert (pair<int,string>(this->litNumeroEntero,"Literal_Entero"));
		lexemas.insert (pair<int,string>(this->litNumeroReal,"Literal_Real"));
		lexemas.insert (pair<int,string>(this->litIdentificador,"Literal_Identificador"));
		lexemas.insert (pair<int,string>(this->litCadena,"Literal_Cadena"));
		lexemas.insert (pair<int,string>(this->litCaracter,"Literal_Caracter"));
		lexemas.insert (pair<int,string>(this->enter,"Fin de Linea"));
		lexemas.insert (pair<int,string>(this->fin_archivo,"Fin de Archivo"));


	}

	~TokenType(void)
	{
	}

	multimap<string,int>::iterator find(string lexema){
		
		for(size_t i=0; i<lexema.length();i++){
			lexema[i]=toupper(lexema[i]);
		}

		return reservadas.find(lexema);
	}


	string returntokenstring(int token){
		string val="";
		it2=lexemas.find(token);
		val= it2->second;
		return val;
	}

	enum {
		oprSuma,
		oprResta,
		oprLogicoO,
		oprLogicoY,
		oprExpo,
		oprMult,
		oprDiv,
		oprMenor,
		oprMayor,
		oprIgual,
		oprMenorIgual,
		oprMayorIgual,
		oprAsig,
		oprDist,
		pntcorIzq,
		pntcorDer,
		pntComa,
		pntDosPuntos,
		pntPunto,
		pntparDer,
		pntparIzq,
		revFuncion,
		revEntero,
		revReal,
		revCaracter,
		revBooleano,
		revCadena,
		revInicio,
		revFin,
		revSi,
		revNo,
		revEntonces,
		revSino,
		revCaso,
		revPara,
		revHasta,
		revHaga,
		revMientras,
		revRepita,
		revAbrir,
		revCerrar,
		revComo,
		revVar,
		revLeer,
		revEscribir,
		revTipo,
		revArchivo,
		revSecuencial,
		revRegistro,
		revArreglo,
		revDe,
		revProcedimiento,
		revLlamar,
		revEscriba,
		revLea,
		revVerdadero,
		revFalso,
		revDiv,
		revMod,
		revEs,
		revLectura,
		revEscritura,
		revRetorne,
		litNumeroEntero,
		litNumeroReal,
		litIdentificador,
		litCadena,
		litCaracter,
		enter,
		fin_archivo
	};

	
};

